﻿/* File Created: novembar 4, 2011 */
var chatContainer, bottomBarChat, socialModul;

obj.ShowChatBox = function () {

    if (chatContainer === undefined || bottomBarChat === undefined) {
        chatContainer = $(".ChatContainer");
        bottomBarChat = $(".bottomBarChat");
    }
    if (chatContainer.css("display") == "none") {
        chatContainer.css("display", "block");
        bottomBarChat.css("opacity", "0.7");
    }
    else {
        $(".ChatContainer").css("display", "none");
        bottomBarChat.css("opacity", "1").empty().append('Close Chat');
    }
};

obj.ShowSocialNetworks = function () {
    if (socialModul === undefined) {
        socialModul = $(".SocialModul");
    }
    socialModul.animate({
        top: 0
    }, 3000, function () {
        socialModul.css("zIndex", 1);
    });
};

obj.adjustAfterAjax = function (settings) {

    var menuItem = ["Home", "Portfolio", "About", "Skills"], menuIndex, urlObject = obj.getUrlWithoutDomain(settings.url);

    for (var i = 0; i < menuItem.length; i++) {
        if (urlObject.urlArray[0] == menuItem[i]) {
            menuIndex = i;
            break;
        }
    }
    if (urlObject.urlArray.length > 1) {

        for (var i = 0; i < menuItem.length; i++) {
            if (urlObject.urlArray[1] == menuItem[i]) {
                menuIndex = i;
                break;
            }
        }
    }

    switch (menuIndex) {
        case 1:
            $("#menuPointer").css("margin-left", 230);
            break;
        case 2:
            $("#menuPointer").css("margin-left", 360);
            break;
        case 3:
            $("#menuPointer").css("margin-left", 510);
            break;
        default:
            $("#menuPointer").css("margin-left", 75);

    }
    if (!window.statePopped) {
        window.history.pushState(null, urlObject.urlString, urlObject.urlString);
    }
    window.statePopped = false;
    $("#menuPointer").show();
};

obj.getUrlWithoutDomain = function (UrlFull) {
    var response = {}, i, temp;

    //skini visak
    UrlFull = UrlFull.replace("?X-Requested-With=XMLHttpRequest", "");
    UrlFull = UrlFull.replace("X-Requested-With=XMLHttpRequest", "");
    UrlFull = UrlFull.replace("http://", "");
    response.urlArray = UrlFull.split(/\/+/g);
    response.urlArray.splice(0, 1);

    response.urlString = '';
    for (i = 0; i < response.urlArray.length; i++) {
        response.urlString += '/' + response.urlArray[i];
    }
    return response;
};






